package com.woniuxy.userapp.common;


import com.woniuxy.commons.util.Result;
import com.woniuxy.userapp.common.exception.WoniuException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobleExceptionHandler {

    //    蜗牛学院整体项目异常
    @ExceptionHandler(WoniuException.class)
    public Result handlerWoniuxyException(WoniuException e){
        return Result.getInstance().setCode(e.getCode()).setMsg(e.getMessage());
    }


    //    //兜底异常 除自定义异常的以外的系统异常 会走到这里返回
    @ExceptionHandler(Exception.class) //
    public Result handlerException(Exception e){
        return Result.getInstance().setCode(500).setMsg(e.getMessage());
    }
}
